// pages/shoppingCar/shoppingCar.js
const shopping = require("../../utils/shopping.js")
const eventBus = require('../../utils/eventbus.js');
Page({
  data: {
    Car:""
  },
  onLoad: function (options) {
     this.setData({
       Car: wx.getStorageSync("shoppingCar").items
     })
  },
  incress(e){
    let pid = e.currentTarget.dataset.pid
    shopping.incress(pid)
    this.setData({
      Car: wx.getStorageSync("shoppingCar").items
    })
    eventBus.emit('refreshCartCount')
  },
  decress(e){
    let pid = e.currentTarget.dataset.pid
    shopping.decress(pid)
    this.setData({
      Car: wx.getStorageSync("shoppingCar").items
    })
    eventBus.emit('refreshCartCount')
  },
  pay(){
    let car=JSON.stringify(this.data.Car)
    console.log(car)
    wx.navigateTo({
      url: '../preview/preview?car='+car
    })
  }
})